# Created by the script create_makefile
# This is the makefile for compiling a CGAL application.

#---------------------------------------------------------------------#
#                    include platform specific settings
#---------------------------------------------------------------------#
# Choose the right include file from the <cgalroot>/make directory.

# CGAL_MAKEFILE = ENTER_YOUR_INCLUDE_MAKEFILE_HERE
#CGAL_MAKEFILE = /usr/local/CGAL-3.2.1/make/makefile_i686_Linux-2.6_g++-4.2.3
#CGAL_MAKEFILE = /usr/local/CGAL-3.3.1/make/makefile_i686_Linux-2.6_g++-4.2.3
#CGAL_MAKEFILE = /usr/local/CGAL-3.3.1/make/makefile_i686_Linux-2.6_g++-4.1-4.1.3
CGAL_MAKEFILE = /f/vs2k5project/CGAL-3.3.1/make/makefile_i686_MINGW32NT-5.1_g++-3.4.5

include $(CGAL_MAKEFILE)


#MATLAB_INC_DIR = /usr/local/matlab/extern/include
#MATLAB_LIB_DIR1 = /usr/local/matlab/bin/glnx86
#MATLAB_LIB_DIR2 = /usr/local/matlab/sys/os/glnx86

CUR_DIR = /f/vs2k5project/pcdimpl
LIB_DIR = /f/vs2k5project/mlibrary

ARPACKPP_DIR = $(LIB_DIR)/arpackpp
ARPACKPP_INC = $(ARPACKPP_DIR)/include
ARPACKPP_NONSYM_INC = $(ARPACKPP_DIR)/nonsymmatrices
SUPERLU_DIR  = $(LIB_DIR)/SuperLU
SUPERLU_INC = $(SUPERLU_DIR)/SRC
UMFPACK_DIR  = $(LIB_DIR)/UMFPACK
GSL_DIR = $(LIB_DIR)/gsl-1.11
CSPARSE_DIR = $(LIB_DIR)/CSparse
CSPARSE_INC = $(CSPARSE_DIR)/Include

ARPACK_DIR = $(LIB_DIR)/ARPACK
ARPACK_LIB   = $(ARPACK_DIR)/libarpack.a
LAPACK_LIB   = $(LIB_DIR)/LAPACK/lapack.a
UMFPACK_LIB  = $(UMFPACK_DIR)/Lib/libumfpack.a
SUPERLU_LIB  = $(SUPERLU_DIR)/lib/libsuperlu_3.1.a
BLAS_LIB     = $(LIB_DIR)/LAPACK/blas.a
GSL_LIB = $(GSL_DIR)/.libs/libgsl.a
CSPARSE_LIB = $(CSPARSE_DIR)/Lib/libcsparse.a

EXEC_OUT = main.exe

#---------------------------------------------------------------------#
#                    compiler flags
#---------------------------------------------------------------------#

CXXFLAGS = \
      $(CGAL_CXXFLAGS) \
      $(LONG_NAME_PROBLEM_CXXFLAGS) \
      -I$(ARPACKPP_INC)\
	  -I$(ARPACKPP_NONSYM_INC)\
	  -I$(CSPARSE_INC)\
      -O2\
#      -g

#---------------------------------------------------------------------#
#                    linker flags
#---------------------------------------------------------------------#

LIBPATH = \
#          .

LDFLAGS = \
	$(LONG_NAME_PROBLEM_LDFLAGS) \
	$(CGAL_LDFLAGS) 


LDFLAGS_CGAL = \
	$(LONG_NAME_PROBLEM_LDFLAGS) \
	$(CGAL_LDFLAGS) \
			  -lXmu -lXi  -lXt -lXext -lICE \
			  -lpthread  -static

LDFLAGS_SO = \
			$(LAPACK_LIB)\
			$(BLAS_LIB)\
			$(ARPACK_LIB)\
			$(CSPARSE_LIB)\
			/lib/libg2c.a



#--------------------------------------------------------------------#
#                    target entries
#---------------------------------------------------------------------#

AR = ar
ARFLAGS = cru
LIBEXT = .a
SOBJ_EXT = .so

all:  \
	point_cloud$(OBJ_EXT)\
	lpmatrix$(OBJ_EXT)\
	comp_llpmatrix$(OBJ_EXT)\
	main$(OBJ_EXT)\
	pcdwrapper$(OBJ_EXT)\
	lapackUtil$(OBJ_EXT) \
	graphlap$(OBJ_EXT) \
	graph.exe \
	tpcd.exe  \
	pcdqb.exe
#	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) main.cc -o main$(OBJ_EXT)
#	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) comp_llpmatrix.cc -o comp_llpmatrix$(OBJ_EXT)
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) lapackUtil.cc -o lapackUtil$(OBJ_EXT)
#	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) pcdwrapper.cc -o pcdwrapper$(OBJ_EXT)
	$(CGAL_CXX) $(OBJ) $(LDFLAGS) $(LDFLAGS_SO) -o $(EXEC_OUT)
#	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) graphlap.cc -o graphlap$(OBJ_EXT)
#	$(CGAL_CXX) $(OBJ_GRAPH) $(LDFLAGS) $(LDFLAGS_SO) -o graph.exe
#	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) tpcd.cc -o tpcd$(OBJ_EXT)
#	$(CGAL_CXX) $(OBJ_TPCD) $(LDFLAGS) $(LDFLAGS_SO) -o tpcd.exe
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) pcdqb.cc -o pcdqb$(OBJ_EXT)
	$(CGAL_CXX) $(OBJ_PCDQB) $(LDFLAGS) $(LDFLAGS_SO) -o pcdqb.exe

OBJ	=  \
		point_cloud$(OBJ_EXT)     		\
		comp_llpmatrix$(OBJ_EXT)		\
		lpmatrix$(OBJ_EXT)\
		main$(OBJ_EXT)\
		pcdwrapper$(OBJ_EXT)\
		lapackUtil$(OBJ_EXT)

OBJ_GRAPH = graphlap$(OBJ_EXT) \
		point_cloud$(OBJ_EXT)     		\
		comp_llpmatrix$(OBJ_EXT)		\
		lpmatrix$(OBJ_EXT)\
		pcdwrapper$(OBJ_EXT)\
		lapackUtil$(OBJ_EXT)

OBJ_TPCD = tpcd$(OBJ_EXT) \
		point_cloud$(OBJ_EXT)     		\
		comp_llpmatrix$(OBJ_EXT)		\
		lpmatrix$(OBJ_EXT)\
		pcdwrapper$(OBJ_EXT)\
		lapackUtil$(OBJ_EXT)

OBJ_PCDQB = pcdqb$(OBJ_EXT) \
		point_cloud$(OBJ_EXT)     		\
		comp_llpmatrix$(OBJ_EXT)		\
		lpmatrix$(OBJ_EXT)\
		pcdwrapper$(OBJ_EXT)\
		lapackUtil$(OBJ_EXT)

pcdqb.exe: $(OBJ_PCDQB)
		$(CGAL_CXX) $(OBJ_PCDQB) $(LDFLAGS) $(LDFLAGS_SO) -o pcdqb.exe


tpcd.exe: $(OBJ_TPCD)
		$(CGAL_CXX) $(OBJ_TPCD) $(LDFLAGS) $(LDFLAGS_SO) -o tpcd.exe

tpcd$(OBJ_EXT):
		$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) tpcd.cc -o tpcd$(OBJ_EXT)

graph.exe: $(OBJ_GRAPH)
	$(CGAL_CXX) $(OBJ_GRAPH) $(LDFLAGS) $(LDFLAGS_SO) -o graph.exe
		
graphlap$(OBJ_EXT):
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) graphlap.cc -o graphlap$(OBJ_EXT)

main$(OBJ_EXT):
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) main.cc -o main$(OBJ_EXT)

point_cloud$(OBJ_EXT): 
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) point_cloud.cc -o point_cloud$(OBJ_EXT)

lpmatrix$(OBJ_EXT):
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) lpmatrix.cc -o lpmatrix$(OBJ_EXT)

comp_llpmatrix$(OBJ_EXT):
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) comp_llpmatrix.cc -o comp_llpmatrix$(OBJ_EXT)

pcdwrapper$(OBJ_EXT):
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) pcdwrapper.cc -o pcdwrapper$(OBJ_EXT)

lapackUtil$(OBJ_EXT):
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) lapackUtil.cc -o lapackUtil$(OBJ_EXT)

pcdqb$(OBJ_EXT):
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) pcdqb.cc -o pcdqb$(OBJ_EXT)


clean:	
		rm -f  $(OBJ) $(OBJ_GRAPH) $(OBJ_TPCD) $(OBJ_PCDQB) $(EXEC_OUT) graph.exe tpcd.exe pcdqb.exe



run: $(EXEC_OUT)
#		./$(EXEC_OUT) homer_sub.m pcd_homer.txt sym_pcd_homer.txt sym_pcd_homer_b.txt sym_pcd_homer_v.txt sym_pcd_homer_d.txt
#		./$(EXEC_OUT) sphere.m pcd_sphere.txt sym_pcd_sphere.txt sym_pcd_sphere_b.txt sym_pcd_v.txt sym_pcd_d.txt
		./$(EXEC_OUT) cube.m pcd_sphere.txt sym_pcd_cube.txt sym_pcd_cube_b.txt sym_pcd_cube_v.txt sym_pcd_cube_d.txt

rungraph: graph.exe
#		./graph.exe sphere_graph.txt sphere_graph_v.txt sphere_graph_d.txt
		./graph.exe homer_graph.txt homer_graph_q.txt

runtpcd: tpcd.exe
#		./tpcd.exe sphere.m sphere_tpcd_v.txt sphere_tpcd_d.txt
		./tpcd.exe homer_sub.m homer_tpcd_q.txt

#---------------------------------------------------------------------#
#                    suffix rules
#---------------------------------------------------------------------#



.C$(OBJ_EXT):
	$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $<

